package cloud.keveri.chat4j.api.entity.chat;

import cloud.keveri.chat4j.api.group.ChatgptGroup;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * chat请求
 * <p>
 * 作者：沈自在
 **/

@Data
@Builder
@Accessors(chain = true)
public class CompletionRequest implements Serializable {

    /**
     * 模型
     */
    private String model;

    /**
     * 消息
     */
    @NotNull(groups = {ChatgptGroup.class})
    @Size(min = 1, max = 1, groups = {ChatgptGroup.class})
    private List<Message> messages;

    /**
     *
     */
    private Double temperature;

    /**
     *
     */
    private Double topP;

    /**
     *
     */
    private Integer n;

    /**
     *
     */
    private Boolean stream;

    /**
     *
     */
    private Integer maxTokens;

    /**
     *
     */
    private Double presencePenalty;

    /**
     *
     */
    private Double frequencyPenalty;

    /**
     * 停止输出标记
     */
    private List<String> stop;

    /**
     *
     */
    private Map<?, ?> logitBias;

    /**
     *
     */
    private String user;

    public Boolean isStream(){
        if (stream == null) {
            return Boolean.FALSE;
        }
        return stream;
    }
}
